home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS26.ADF
/
Tartan
/
Tartan5
< prev
next >
Wrap
Text File
|
1989-01-26
|
7KB
|
354 lines
'TARTAN AmigaBASIC program
'Richard Taylor Glastonbury Conn
DEFINT a-z
DEF FNL(h%,w,p)= INT(3+2*(h%+1)*INT((w+16)/16)*p/2)
DIM sett(2,40),mx(4,4),ra$(2,20)
'For initial checkout, use "depth=2"
'When checkout complete, use "depth=4"
depth = 4
'Set up the twill "weave" pattern
FOR i = 1 TO 4: FOR j = 1 TO 4
READ mx(i,j)
NEXT j: NEXT i
DATA 1,1,0,0,1,0,0,1,0,0,1,1,0,1,1,0
GOSUB InitRA
IF depth > 2 THEN
SCREEN 1,640,200,depth,2
WINDOW 1,"TARTAN",,31,1
END IF
'Keep default colors 0-3
'Define colors 4-15
FOR i = 4 TO 15
READ r!,g!,b!
PALETTE i,r!,g!,b!
NEXT i
' 4=red 5=med red 6=brick 7=buff
DATA .9,0,0, .64,0,0, .5,.2,.2, .75,.54,.29
' 8=green 9=med green 10=dk grn 11=yellow
DATA 0,.7,0, .29,.54,.29, 0,.36,.11, .9,.9,0
' 12=purple 13=dk prpl 14=lt blue 15=dk blue
DATA .85,0,.85, .35,0,.45, .5,.6,.8, 0,.18,.5
MENU 1,0,0,"Project"
MENU 1,1,1,"Control"
MENU 1,2,1,"Quit "
MENU 2,0,0,""
MENU 3,0,0,""
MENU 4,0,0,""
ON MENU GOSUB L030
MENU ON
GOSUB Control
L020:
WHILE MOUSE(0) = 0: WEND 'Main Loop
GOTO L020
L030:
menuID = MENU(0)
itemID = MENU(1)
ON menuID GOSUB L040
RETURN
L040:
IF itemID = 2 THEN
IF depth > 2 THEN
WINDOW CLOSE 1
SCREEN CLOSE 1
WINDOW 1,"BASIC",,31,-1
END IF
MENU RESET
END
END IF
ON itemID GOSUB Control
RETURN
'Construct the Tartan and display it
Display:
CLS: MENU 1,0,1
'Convert numeric characters of ra$
'to numeric digits in sett
totLines = 0
FOR i = 1 TO 2
FOR j = 1 TO ns
v = 0
FOR k = 1 TO 2
c$ = MID$(ra$(i,j),k,1)
IF c$ >= "0" AND c$ <= "9" THEN v = 10*v+ASC(c$)-48
NEXT k
sett(i,j) = v
IF i = 1 THEN totLines = totLines + v
NEXT j
NEXT i
'Double the sett by appending its mirror image
FOR i = 1 TO ns
j = 2*ns+1-i
sett(1,j) = sett(1,i)
sett(2,j) = sett(2,i)
NEXT i
ns = 2*ns
' "Weave" the basic square
imx = 0: iy = 0
FOR ia = 1 TO ns
nf = sett(1,ia) 'No. of weft lines
colf = sett(2,ia) 'Weft color
FOR ib = 1 TO nf 'Defines a weft line
imx = imx+1
IF imx > 4 THEN imx = 1
jmx = 0: iy = iy+1: ix = 0
FOR ic = 1 TO ns
np = sett(1,ic) 'No. of warp lines
colp = sett(2,ic) 'Warp color
FOR id = 1 TO np 'Defines a warp line
jmx = jmx+1
IF jmx > 4 THEN jmx = 1
IF mx(imx,jmx) = 1 THEN col = colf ELSE col = colp
LINE (ix,iy)-(ix+2,iy),col
ix = ix+3
NEXT id
NEXT ic
NEXT ib
NEXT ia
IF totLines > 52 THEN L050
'Fill the screen
iz = FNL(iy+1,ix+1,depth)
DIM a(iz)
GET (0,0)-(ix,iy),a
ixn = INT(640/ix)
iyn = INT(200/iy)
CLS
FOR i = 0 TO ixn*ix STEP ix
FOR j = 0 TO iyn*iy STEP iy
PUT (i,j),a
NEXT j
NEXT i
ERASE a
L050:
ns = ns/2
RETURN
'Show TARTAN CONTROL panel
Control:
CLS: MENU 1,0,0
LOCATE 4,1
j = 14
FOR i = 0 TO 2^depth-1
PRINT TAB(j);i;
j = j+4
' IF i < 8 THEN k=i ELSE k=i-8
LINE (33*i+94,10)-(33*(i+1)+94,20),i,bf
NEXT i
LINE (93,9)-(617,21),2,b
LOCATE 1,20: PRINT "- - - - C o l o r M e n u - - - -"
COLOR 3,2
LOCATE 2,2: PRINT " TARTAN "
LOCATE 3,2: PRINT " CONTROL "
COLOR 1,0
LOCATE 5,3: PRINT "0"
LINE (8,29)-(32,42),,b
LOCATE 6,6: PRINT "Lines Color"
ef = 0: GOSUB PData
L150:
COLOR 2,3
LINE (8,138)-(80,156),3,bf
LOCATE 19,3: PRINT "DISPLAY"
LINE (105,138)-(145,156),3,bf
LOCATE 19,15: PRINT "NEW"
LINE (184,138)-(246,156),3,bf
LOCATE 19,25: PRINT "CHANGE"
LINE (264,138)-(326,156),3,bf
LOCATE 19,35: PRINT "DELETE"
LINE (344,138)-(406,156),3,bf
LOCATE 19,45: PRINT "INSERT"
COLOR 1,0
LOCATE 17,36: PRINT "EDIT"
LINE (174,126)-(416,164),,b
L160:
COLOR 1,0: WHILE MOUSE(0) = 0: WEND
IF MOUSE(0) = 0 THEN L160
xm = MOUSE(1): ym = MOUSE(2)
IF ym >= 138 AND ym <= 156 THEN
IF xm >= 8 AND xm <= 80 THEN 'Display
IF ns < 2 THEN
msg$ = "Need 2 or more items for DISPLAY."
GOSUB ErrPrt: GOTO L160
END IF
GOTO L170
END IF
IF xm >= 105 AND xm <= 145 THEN 'New
GOSUB InitRA
CLS: ns = 0
GOTO Control
END IF: COLOR 3,2
IF xm >= 184 AND xm <= 246 THEN 'Change
LOCATE 19,25: PRINT "CHANGE"
F$ = "C": GOTO L160
END IF
IF xm >= 264 AND xm <= 326 THEN 'Delete
LOCATE 19,35: PRINT "DELETE"
F$ = "D": GOTO L160
END IF
IF xm >= 344 AND xm <= 406 THEN 'Insert
IF ns = 20 THEN
msg$ = "Max of 20 items allowed."
GOSUB ErrPrt: GOTO L160
END IF
LOCATE 19,45: PRINT "INSERT"
F$ = "I": GOTO L160
END IF
END IF
IF F$ = "C" OR F$ = "D" OR F$ = "I" THEN
IF xm < 8 OR xm > 470 THEN L160
IF ym < 29 OR ym > 122 THEN L160
xp = 8: yp = 13: xL = 2
FOR k = 0 TO ns
GOSUB BoxC
IF xm >= xp AND xm <= xp+24 THEN
IF ym >= yp AND ym <= yp+13 THEN
IF F$ = "C" AND k > 0 THEN 'Change
ef = k: GOSUB PData
F$ = "": GOTO L150
END IF
IF F$ = "D" AND k > 0 THEN 'Delete
FOR j = k+1 TO ns
ra$(1,j-1) = ra$(1,j)
ra$(2,j-1) = ra$(2,j)
NEXT j
ns = ns-1: F$ = ""
GOTO Control
END IF
IF F$ = "I" THEN 'Insert
FOR j = ns TO k+1 STEP -1
ra$(1,j+1) = ra$(1,j)
ra$(2,j+1) = ra$(2,j)
NEXT j
ns = ns+1: ef = k+1
ra$(1,ef) = "00": ra$(2,ef) = "00"
GOSUB PData
F$ = "": GOTO L150
END IF
END IF
END IF
NEXT k
END IF
GOTO L160
L170:
ef = 0
GOSUB Display
RETURN
'Calc item box coordinates
BoxC:
yp = yp+16: yL = yL+2
IF yp > 109 THEN
xp = xp+146: yp = 45
xL = xL+18: yL = 7
LOCATE 6,xL+4: PRINT "Lines Color"
END IF
RETURN
'Initialize ra$ array
InitRA:
FOR i = 1 TO 2
FOR j = 1 TO 20
ra$(i,j) = "00"
NEXT j
NEXT i
RETURN
'Print error message
ErrPrt:
BEEP: LOCATE 21,1: PRINT msg$
INPUT "Press RETURN to continue.",a$
LOCATE 21,1: PRINT SPACE$(33)
PRINT SPACE$(25): RETURN
'Process items--input, change, insert
PData:
sxp = 0: xp = 8: yp = 29: xL = 2: yL = 5
IF ns = 0 THEN kk = 20 ELSE kk = ns
FOR i = 1 TO kk
GOSUB BoxC
IF ns = 0 THEN
LOCATE yL,xL: PRINT i
LINE (xp,yp)-(xp+24,yp+13),,b
CALL DataSub(xL+5,yL,ra$(1,i))
IF ra$(1,i) = "" THEN
ns = i-1: GOTO L270
END IF
CALL DataSub(xL+10,yL,ra$(2,i))
GOTO L260
END IF
IF ef = 0 THEN
L250:
LOCATE yL,xL: PRINT i
LINE (xp,yp)-(xp+24,yp+13),,b
LOCATE yL,xL+5: PRINT ra$(1,i);" "
LOCATE yL,xL+10: PRINT ra$(2,i);" "
GOTO L260
END IF
IF i < ef THEN L260
IF i > ef THEN L250
IF ra$(1,i) <> "00" THEN
CALL DataSub(xL+5,yL,ra$(1,i))
CALL DataSub (xL+10,yL,ra$(2,i))
GOTO L270
END IF
sxp = xp: syp = yp: si = i
sxL = xL: syL = yL
L260:
NEXT i
IF ns = 0 THEN ns = 20
IF sxp > 0 THEN
IF si = ns THEN
LOCATE syL,sxL: PRINT ns
LINE (sxp,syp)-(sxp+24,syp+13),,b
END IF
CALL DataSub(sxL+5,syL,ra$(1,si))
CALL DataSub(sxL+10,syL,ra$(2,si))
END IF
L270:
RETURN
'Data entry for "Lines" & "Color"
SUB DataSub(xx,yy,d$) STATIC
COLOR 2,1
IF d$ = "00" THEN
LOCATE yy,xx: PRINT " "
d$ = ""
END IF
cur = LEN(d$)
k$ = ""
WHILE k$ <> CHR$(13)
LOCATE yy,xx: PRINT d$;
k$ = ""
WHILE k$ = "": k$ = INPUT$(1): WEND
k = ASC(k$)
IF k >= 48 AND k <= 57 AND cur < 2 THEN
d$ = LEFT$(d$,cur)+k$
cur = cur+1
END IF
IF k = 8 THEN
IF cur > 0 THEN d$ = LEFT$(d$,cur-1)
LOCATE yy,xx: PRINT " "
IF cur > 0 THEN cur = cur-1
END IF
WEND
COLOR 1,0
LOCATE yy,xx: PRINT " "
LOCATE yy,xx: PRINT d$
END SUB